package cn.life.business.user.controller;

import cn.life.business.user.entity.vo.LoginUserVo;
import cn.life.business.user.entity.vo.LoginVo;
import cn.life.business.user.entity.vo.UserInfoVo;
import cn.life.common.entity.model.CMessage;
import cn.life.common.entity.model.MyUserInfo;
import cn.life.common.entity.model.MyUser;
import cn.life.business.user.entity.po.LoginUser;
import cn.life.business.user.entity.po.UserInfo;
import cn.life.business.user.entity.vo.RegisterUserVo;
import cn.life.business.user.service.UserService;
import cn.life.common.support.check.UserInterceptorHandler;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Date;

/**
 * @Description:    用户信息控制层
 *
 * @Author 李佳明
 * @Date 2018/6/14 14:01
 */
@RestController
@RequestMapping("user")
public class UserController {

    private static final Logger logger = LoggerFactory.getLogger(UserController.class);

    @Autowired
    private UserService userService;

    /**
     * @Description:    用户登陆
     *
     * @return:
     *
     * @Author 李佳明
     * @Date  2018/7/16 0016 上午 9:46
     */
    @PostMapping(value = "/key/login")
    public CMessage login(HttpServletRequest request, HttpServletResponse response, @RequestBody LoginVo loginVo) throws IOException {
        return userService.keyLogin(request,response,loginVo);
    }


    /**
     * @Description:    用户登陆(账号密码)
     *
     * @param loginVo
     * @return:
     *
     * @Author 李佳明
     * @Date 2018-10-15 上午 9:39
     */
    @PostMapping(value = "/admin/login")
    public CMessage adminLogin(HttpServletRequest request, HttpServletResponse response, @RequestBody LoginVo loginVo) throws IOException {
        return userService.adminLogin(request,response,loginVo);
    }
}
